<template>
  <div class="block">
    <!--   element plus中有专门的广告轮播的组件  el-carousel -->
    <el-carousel :interval="3000">
      <el-carousel-item v-for="(item, index) in bannerData" :key="index">
        <img
          :src="bannerData[index].pic"
          :alt="bannerData[index].description"
        />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
// 暴露组件属性
export default {
  props: {
    bannerData: {
      type: Array,
      default: () => [],
    },
  },
};
</script>


<style scoped>
.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  /* line-height: 300px; */
  margin: 0;
}
.el-carousel__item img {
  width: 100%; /* 宽度自适应容器 */
  height: 100%; /* 设置固定高度，可以根据需要调整 */
  object-fit: contain; /* 保持图片比例，裁剪多余部分填满容器 */
}
.el-carousel {
  width: 100%;
  height: 200px;
  margin-top: 45px;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>


